package com.bw.base.net

import android.content.Context
import androidx.room.Room
import com.bw.base.db.AppDatabase
import com.bw.base.db.SearchDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ProviderFactry {
    @Singleton
    @Provides
    fun getApiService():ApiService{
        return ReUtils.getRetrofit().create(ApiService::class.java)
    }

    @Singleton
    @Provides
    fun inti(@ApplicationContext context: Context):AppDatabase{
        return Room.databaseBuilder(context,AppDatabase::class.java,"zg3park.db")
            .allowMainThreadQueries()
            .build()
    }

    @Singleton
    @Provides
    fun getDao(appDatabase: AppDatabase):SearchDao{
        return appDatabase.getSearchDao()
    }
}